package com.ozo.easy.controller;

import com.ozo.easy.common.log.annotation.LogAnno;
import com.ozo.easy.common.model.*;
import com.ozo.easy.pojo.dto.SysLogQueryDTO;
import com.ozo.easy.pojo.vo.SysLogVO;
import com.ozo.easy.service.ISysLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.validation.Valid;

/**
 * 系统日志 前端控制器
 *
 * @author ozo
 * @version 1.0
 * @date 2025-02-06 15:13:51
 */
@Tag(name = "系统日志")
@RequiredArgsConstructor
@RestController
@RequestMapping("/sysLog")
public class SysLogController {

    private final ISysLogService sysLogService;

    @Operation(summary = "表格页")
    @GetMapping("/index")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("sysLog/index");
        return modelAndView;
    }

    @LogAnno(value = "删除系统日志", module = "系统日志")
    @Operation(summary = "删除系统日志")
    @DeleteMapping("/remove")
    public ResultVO<Void> remove(@RequestBody @Valid BaseBatchDTO<Long> batchDTO) {
        sysLogService.remove(batchDTO);
        return ResultVO.success();
    }

    @Operation(summary = "系统日志分页")
    @GetMapping("/page")
    public ResultVO<PageResult<SysLogVO>> page(@Valid BasePage basePage, SysLogQueryDTO queryDTO) {
        return ResultVO.success(sysLogService.page(basePage, queryDTO));
    }

}